﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BusinessObjects.BO_GetObjects;
using LibraryO2S;

public partial class Controls_ucListService : System.Web.UI.UserControl
{
    private string category_id;

    public string Category_id
    {
        get { return category_id; }
        set { category_id = value; }
    }
    private string module_name;

    public string Module_name
    {
        get { return module_name; }
        set { module_name = value; }
    }
    private string page_size;

    public string Page_size
    {
        get { return page_size; }
        set { page_size = value; }
    }
    private string module_id;

    public string Module_id
    {
        get { return module_id; }
        set { module_id = value; }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadContent();
        }
    }

    protected void LoadContent()
    {
        int cur_page = Convert.ToInt32(Request["cur_page"]);
        if (cur_page == 0)
            cur_page = 1;
        string url = Request.Url.AbsoluteUri;
        if (url.IndexOf("&cur_page") > 0)
        {
            url = url.Remove(url.IndexOf("&cur_page"));
        }

        url += "&cur_page=$CUR_PAGE";
        DataTable objDT = BO_Services.SelectByCategory(Convert.ToInt32(category_id), cur_page, Convert.ToInt32(page_size));
        if (objDT.Rows.Count > 0)
        {
            pagerContainer.InnerHtml = O2S_Pager.Paging(Convert.ToInt32(page_size), cur_page, Convert.ToInt32(objDT.Rows[0]["row_count"]), url);
            rptListNews.DataSource = objDT;
            rptListNews.DataBind();
        }
        sTitle.InnerText = module_name;
    }


}